<template>
  <v-row v-if="priorityclasses.length !== 0" no-gutters>
    <v-col>
      <v-card class="ma-2" outlined>
        <v-card-title class="mb-1"> PriorityClasses </v-card-title>
        <v-card-actions>
          <v-chip
            v-for="(p, i) in priorityclasses"
            :key="i"
            class="ma-2"
            color="primary"
            outlined
            large
            label
            @click.stop="onClick(p)"
          >
            {{ p.metadata.name }}
          </v-chip>
        </v-card-actions>
      </v-card>
    </v-col>
  </v-row>
</template>

<script lang="ts">
import { V1PriorityClass } from "@kubernetes/client-node";
import { computed, inject, defineComponent } from "@nuxtjs/composition-api";
import {} from "../../lib/util";
import PriorityClassStoreKey from "../../StoreKey/PriorityClassStoreKey";
export default defineComponent({
  setup() {
    const store = inject(PriorityClassStoreKey);
    if (!store) {
      throw new Error(`${PriorityClassStoreKey.description} is not provided`);
    }

    const onClick = (priorityclass: V1PriorityClass) => {
      store.select(priorityclass, false);
    };

    const priorityclasses = computed(() => store.priorityclasses);
    return {
      priorityclasses,
      onClick,
    };
  },
});
</script>
